package com.heaton.videocar.adapter

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import cn.com.heaton.blelibrary.ble.model.BleDevice
import com.heaton.baselib.base.recycleview.RecyclerAdapter
import com.heaton.baselib.base.recycleview.RecyclerViewHolder
import com.heaton.videocar.R

class ConnectAdapter(context: Context, data: List<BleDevice>) : RecyclerAdapter<BleDevice>(context, data) {

    override fun layoutId(): Int {
        return R.layout.item_connect
    }

    override fun convert(holder: RecyclerViewHolder, device: BleDevice) {
        val name = holder.getView<TextView>(R.id.tv_name)
        name.text = device.bleName
        val state = holder.getView<ImageView>(R.id.iv_state)
        if (device.isConnected){
            holder.setVisible(R.id.pb_connecting, false)
        }else if(device.isConnecting){
            holder.setVisible(R.id.pb_connecting, true)
        }else {
            holder.setVisible(R.id.pb_connecting, false)
        }
    }

}